// init
import {init} from '../../util/app';
// plugins
import createLoading from 'dva-loading';
import createEffectLock from '../../plugin/effectLock';
import {createWebLocalStore, getWebState} from '../../plugin/webLocalStore';
import {createLoginSession} from '../../plugin/loginSession';
// models
import login from '../login/model/login';
import register from '../login/model/register';
import forgetPassword from '../login/model/forgetPassword';
import home from './model/home';
import blogDetail from './model/blogDetail';
// router
import router from './router';
// css
import './index.css';

const APP_WEB_STATE = 'WEB_STATE_BLOG';

let initialState = getWebState(APP_WEB_STATE) || {
    login: {
    	channel: 'a3384a9ca39efb36822d0b10b62fbd6c',
		loginRedirect: '/',
		logoutRedirect: '/'
    }
};
// 重置插件属性
if(initialState.loading) delete initialState.loading;// 重置loading
if(initialState.effectLock) delete initialState.effectLock;// 重置effectlock

const dvaApp = init({
    initialState: initialState,
    plugins: [
        createWebLocalStore(APP_WEB_STATE),
        createLoginSession(),
        createLoading(),
        createEffectLock()
    ],
    models: [
        login,
        register,
        forgetPassword,
        home,
        blogDetail,
    ],
    router: router,
    start: '#root'
});